﻿Imports System.Net
Imports System.Web.Http
Imports Models.Security

Namespace Controllers

    Public Class RolController
        Inherits ApiController

        ''' <summary>
        ''' Get Project By Id
        ''' </summary>
        ''' <param name="id"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <AcceptVerbs("GET")> _
        Public Function [Get](id As Integer) As RolVO
            Try
                Dim oService As New Services.Rols(Request)
                Dim oEntity As RolVO = oService.Get(id)
                Return oEntity
            Catch ex As Exception
                apiHelpers.ManageException(ex)
            End Try
        End Function


        ''' <summary>
        ''' Get List of Rols
        ''' </summary>
        ''' <param name="companyId">Optional for filter</param>
        ''' <returns>Array of Projects</returns>
        ''' <remarks></remarks>
        <AcceptVerbs("GET")> _
        Public Function List(companyId As Integer) As Generic.List(Of RolVO)
            Try
                Dim oService As New Services.Rols(Request)
                Return oService.List(companyId)
            Catch ex As Exception
                apiHelpers.ManageException(ex)
                Return Nothing
            End Try
        End Function

        ''' <summary>
        ''' Update project
        ''' </summary>
        ''' <param name="data">project object</param>
        ''' <returns>Boolean</returns>
        ''' <remarks></remarks>
        <AcceptVerbs("PUT")> _
        Public Function Update(data As RolVO) As Integer
            Try
                Dim oService As New Services.Rols(Request)
                Return oService.Update(data)
            Catch ex As Exception
                apiHelpers.ManageException(ex)
                Return -1
            End Try
        End Function

        ''' <summary>
        ''' Create a Project
        ''' </summary>
        ''' <param name="data"></param>
        ''' <returns>The new ID  of the entity</returns>
        ''' <remarks></remarks>
        <AcceptVerbs("POST")> _
        Public Function Create(data As RolVO) As Integer
            Try
                Dim oService As New Services.Rols(Request)
                Return oService.Create(data)
            Catch ex As Exception
                apiHelpers.ManageException(ex)
                Return -1
            End Try
        End Function

        ''' <summary>
        ''' Delete a project
        ''' </summary>
        ''' <param name="id">projectId</param>
        ''' <returns>1 if OK</returns>
        ''' <remarks></remarks>
        <AcceptVerbs("DELETE")>
        Public Function Delete(id As Integer) As Integer
            Try
                Dim oService As New Services.Rols(Request)
                Return oService.Delete(id)
            Catch ex As Exception
                apiHelpers.ManageException(ex)
                Return -1
            End Try
        End Function

    End Class

End Namespace